fix: honor train_bn in BackboneFinetuning.freeze_before_training#21652
fix: honor train_bn in BackboneFinetuning.freeze_before_training#21652javierdejesusda wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #21652 +/- ##
=========================================
- Coverage 87% 79% -8%
=========================================
Files 270 267 -3
Lines 23934 23875 -59
=========================================
- Hits 20713 18798 -1915
- Misses 3221 5077 +1856 |
…ning freeze_before_training() called self.freeze(pl_module.backbone) without forwarding self.train_bn, so BatchNorm layers stayed trainable during the initial frozen phase regardless of the train_bn setting. The unfreezing path already passed the flag correctly.
55c2ea2 to
92a2a3c
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #21652 +/- ##
=========================================
- Coverage 87% 79% -8%
=========================================
Files 270 267 -3
Lines 23973 23914 -59
=========================================
- Hits 20751 18801 -1950
- Misses 3222 5113 +1891 |
What does this PR do?
Fixes #21531
BackboneFinetuning.freeze_before_training()calledself.freeze(pl_module.backbone)without forwarding thetrain_bnparameter, so BatchNorm layers stayed trainable during the initial frozen phase regardless of thetrain_bnsetting passed to the constructor.The unfreezing path in
finetune_function()already passedtrain_bn=self.train_bncorrectly — this change makes the freezing path consistent.Before submitting
BackboneFinetuning:train_bnonly applied during unfreezing phase #21531)📚 Documentation preview 📚: https://pytorch-lightning--21652.org.readthedocs.build/en/21652/